package com.zcgk.core.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/****************************************************
 *
 * 分页对象
 *
 *
 * @author Francis
 * @date 2020/2/4 17:12
 * @version 1.0
 **************************************************/
@Data
@NoArgsConstructor
@ApiModel("分页对象")
@Accessors(chain = true)
public class DefaultPage<T> implements Serializable {
	private static final long serialVersionUID = 1L;

	@ApiModelProperty("分页条数，默认20条")
    private Long pageSize = 20L;

    @ApiModelProperty("当前页数, 默认第一页")
    private Long currentPage = 1L;

    @ApiModelProperty(value = "总页数", hidden = true)
    private Long totalPage;

    @ApiModelProperty(value = "总条数", hidden = true)
    private Long totalRecords;

    @ApiModelProperty(value = "排序规则，字段名.asc或者desc，示例：user_name.asc")
    private String orderRules;

    @ApiModelProperty("是否查询总条数（默认true)，在不需要显示总条数和总页数的设置为false")
    private Boolean searchCount = true;


    public DefaultPage(Long pageSize, Long currentPage) {
        this.pageSize = pageSize;
        this.currentPage = currentPage;
    }


    public DefaultPage(Long pageSize, Long currentPage, String orderRules) {
        this.pageSize = pageSize;
        this.currentPage = currentPage;
        this.orderRules = orderRules;
    }


}
